package io;

import java.io.*;

/**
 *    在流连接中使用PrintWriter
 */
public class PWDemo2 {
    public static void main(String[] args) throws FileNotFoundException, UnsupportedEncodingException {
        //低级流  用于向文件中写入字节
        FileOutputStream fos = new FileOutputStream("pw.txt");

        //高级流  1.衔接字节与字符流  2.将写出的字符转换为字节
        OutputStreamWriter osw = new OutputStreamWriter(fos,"UTF-8");

        //高级流  块写文本数据加速
        BufferedWriter bw = new BufferedWriter(osw);

        //高级流  自动行刷新,按行写出字符串
        PrintWriter pw = new PrintWriter(bw);

        pw.println("nihao");
        pw.println("lsp");
        pw.close();
    }
}
